<?php

class myUser extends sfGuardSecurityUser {

    private $userProfileUins;
    private $defaultProfileUins;

    public function getDefaultProfileUins() {
        if ($this->defaultProfileUins == null) {
            $this->getProfileUin();
        }
        return $this->defaultProfileUins;
    }

    public function getProfileUin() {
        if ($this->userProfileUins == null) {

            $this->userProfileUins = array();
            $this->defaultProfileUins = array();

            if ($this->getGuardUser() != null) {
                $userProfiles = $this->getGuardUser()->getUserProfileMapping();

                foreach ($userProfiles as $currProfile) {
                    $this->userProfileUins[] = $currProfile->getCollectionItemUin();
                    /**
                     * If the profile is a default profile then add it too the
                     * list of defaults
                     */
                    if ($currProfile->getDefaultProfile()) {
                        $this->defaultProfileUins[] = $currProfile->getCollectionItemUin();
                    }
                }
            }
            return $this->userProfileUins;
        } else {
            return $this->userProfileUin;
        }
    }

}